home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93a.txt
/
000075_icon-group-sender _Mon Mar 1 10:01:08 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-04-21
|
2KB
Received: by cheltenham.cs.arizona.edu; Mon, 1 Mar 1993 11:56:07 MST
Date: Mon, 1 Mar 93 10:01:08 PST
From: alex@laguna.Metaphor.COM (Bob Alexander)
Message-Id: <9303011801.AA10630@laguna.Metaphor.COM>
To: icon-group@cs.arizona.edu, rjhare@festival.ed.ac.uk
Subject: Re: environment variables
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
>How do I change the value of an environment variable from within Icon?
As you probably know, processes (like Icon) can't influence the
environment variables in their parent shell. But there might be hope,
depending on exactly what it is you are really trying to accomplish.
If you are changing the environment to pass to a command invoked from
within Icon, the environment variable can be set in the same system()
call:
system("MY_VAR=abc command")
This construct in the Bourne shell will temporarily add "MY_VAR" to the
environment passed to "command", but that change will be forgotton when
the Icon program terminates; it will even be forgotten in subsequent
system() calls in the same program, since the subshell containing your
new definition terminates before the system() call returns to you.
Here's a trick I've used when I want my Icon program to change my base
shell environment. Pass a value back as standard output, then actually
set the variable in the shell itself. For example, if you want to
modify the value of $PATH , make a program "my_prog" that prints the
new value to standard output and issue the following shell command:
PATH=`my_prog`
This line can be encapsulated in a file, but that file must be invoked
by the "." command ("source" command in C shell). Normal command file
(shell script) invocation causes the file's commands to execute in a
subshell and, therefore, they won't influence your base shell. In C
shell, the above line can more conveniently be encapsulated in an
alias, since aliases don't (necessarily) create subshells.
-- Bob Alexander
Metaphor Computer Systems (415) 966-0751 alex@metaphor.com
Mountain View, CA ...{uunet}!{decwrl,apple}!metaphor!alex